﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SiGeSIB
{
    public partial class FormTestDedaGrid : Form
    {
        public FormTestDedaGrid()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _FillTable();
        }

        public void _FillTable()
        {
            DataTable dt = _CreateDataTable();
            Random rd = new Random();
            List<object[]> objs = new List<object[]>();

            for (int i = 0; i < 45; i++)
            {
                decimal perc = Convert.ToDecimal(rd.NextDouble());
                decimal pg = Convert.ToInt32(rd.NextDouble() * 1000);
                object[] obj = new object[]
                {
                    string.Concat("Agrupamento ",(i % 17).ToString()),
					string.Concat("Grupo ",(i % 4).ToString()),
                    string.Concat("Nome",(i % 8).ToString()),
                    string.Concat("Sobrenome ",(i % 12).ToString()),
                    pg,
                    pg*perc,
                    pg* (1-perc)
                };
                objs.Add(obj);
                dt.Rows.Add(obj);
            }

            try
            {
				//uDedaGrid1.SetDataBinding(dt);
				uDedaGrid1.SetDataBinding(dt, new List<string>() { "Grupo", "Sobrenome" });

				this.Activate();
            }
            catch
            {

                throw;
            }
        }

        private DataTable _CreateDataTable()
        {
            DataTable dt = new DataTable();
			dt.Columns.Add(new DataColumn("Agrupamento", typeof(string)));
            dt.Columns.Add(new DataColumn("Grupo", typeof(string)) { Caption = "Grupo" });
            dt.Columns.Add(new DataColumn("Nome", typeof(string)));
            dt.Columns.Add(new DataColumn("Sobrenome", typeof(string)));
            dt.Columns.Add(new DataColumn("Pagou", typeof(decimal)));
            dt.Columns.Add(new DataColumn("Dízimo", typeof(decimal)));
            dt.Columns.Add(new DataColumn("Doação", typeof(decimal)));

            return dt;
        }

		private void button1_Click(object sender, EventArgs e)
		{
			uDedaGrid1.GetSelectedRow();
		}
    }
}
